package com.maychat.pojo;

import com.github.pagehelper.Page;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class RowsWithTotal<T> {
    private long total;
    private List<T> rows;

    public static <U> RowsWithTotal<U> of(Page<U> p) {
        return new RowsWithTotal<>(p.getTotal(), p.getResult());
    }

    public static <U> RowsWithTotal<U> of(List<U> list) {
        Page<U> p = (Page<U>) list;
        return of(p);
    }
}
